package com.hhd.flow.support;

import com.hhd.flow.engine.lisener.FlowListener;
import com.hhd.flow.engine.lisener.FlowListenerAnnotation;
import com.hhd.flow.engine.lisener.event.CreateUserTaskEvent;
import com.hhd.flow.engine.support.FlowFormSupport;
import com.hhd.flow.engine.support.FlowFormSupportAnnotation;
import com.hhd.flow.engine.variable.FlowVariablesContainer;
import com.hhd.flow.engine.variable.impl.JSONFlowVariablesContainer;
import com.hhd.flow.entity.FlowProcessInstance;
import com.hhd.flow.entity.FlowUserTask;

import java.util.List;

//@FlowFormSupportAnnotation(formType = "test")
//@FlowListenerAnnotation(formType = "test")
public class TestFormSupport implements FlowFormSupport, FlowListener {
    @Override
    public FlowVariablesContainer loadVariableContainer(String formTypeId, String formId, FlowProcessInstance processInstance) {
        return new JSONFlowVariablesContainer(Student.class, new Student());
    }

    @Override
    public void onCreateUserTaskEvent(CreateUserTaskEvent event) {
        List<FlowUserTask> flowUserTasks = event.getFlowUserTasks();
        System.out.println("创建了用户任务!!**************************************");
        for (FlowUserTask flowUserTask : flowUserTasks) {
            System.out.println(flowUserTask.getTaskName() + " --> " + flowUserTask.getUsername());
        }
        System.out.println("**************************************");
    }
}
